
#include <cstdio>
#include <cmath>
#define eps 1e-8

struct point{double x,y;};

point intersection(point u1,point u2,point v1,point v2){
    point ret=u1;
    double t=((u1.x-v1.x)*(v1.y-v2.y)-(u1.y-v1.y)*(v1.x-v2.x))
            /((u1.x-u2.x)*(v1.y-v2.y)-(u1.y-u2.y)*(v1.x-v2.x));
    ret.x+=(u2.x-u1.x)*t;
    ret.y+=(u2.y-u1.y)*t;
    return ret;
}

point ptoline(point p,point l1,point l2){
    point t=p;
    t.x+=l1.y-l2.y,t.y+=l2.x-l1.x;
    return intersection(p,t,l1,l2);
}

int main( )
{
    int t;
    point m1, m2, s, e, p;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &m1.x, &m1.y, &m2.x, &m2.y, &s.x, &s.y, &e.x, &e.y);
        p = ptoline( s, m1, m2 );
        p.x += p.x - s.x;
        p.y += p.y - s.y;
        if ( fabs( p.x - e.x ) <= eps && fabs( p.y - e.y ) <= eps )
        {
            printf("%.3lf %.3lf\n", p.x + eps, p.y + eps);
            continue;
        }
        p = intersection( p, e, m1, m2 );
        printf("%.3lf %.3lf\n", p.x + eps, p.y + eps);
    }
    return 0;
}
